//
//  ZCPrizeViewController.m
//  zctx
//
//  Created by apple on 16/2/25.
//  Copyright © 2016年 sanliang. All rights reserved.
//

#import "ZCPrizeViewController.h"

@interface ZCPrizeViewController ()

@end

@implementation ZCPrizeViewController

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear: animated];
    [self.navigationController setNavigationBarHidden:YES];
    self.tabBarController.hidesBottomBarWhenPushed = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    self.timeLable.textColor = [UIColor colorWithHexString:@"737373"];
    self.guizeLable.textColor = [UIColor colorWithHexString:@"C92B2F"];
    self.contentOneLable.textColor = [UIColor colorWithHexString:@"000000"];
    self.contentTwoLable.textColor = [UIColor colorWithHexString:@"000000"];
    self.contentThreeLable.textColor = [UIColor colorWithHexString:@"000000"];
    
    if (IS_IPHONE_4_OR_LESS) {
        self.backConstraint.constant = 15;
        self.imgViewTopHeight.constant = 70;
        self.guizeContraint.constant = 25;
        self.guizeWidth.constant = 240;
        self.ContentContraint.constant = 15;
        self.titleContraint.constant = 15;
    }else if (IS_IPHONE_5){
        self.backConstraint.constant = 15;
        self.guizeWidth.constant = 240;
        self.titleContraint.constant = 20;
    }else if (IS_IPHONE_6){
        
    }else{
        
    }
    [self requestyaoyiyaoCount];
}

-(void)requestyaoyiyaoCount{
    //抽奖情况
    [NetworkManager requestAcsuzhouPrizeRecordmid:UserModel.mid password:UserModel.password success:^(NSDictionary *dict) {
        
        if ([[dict objectForKey:@"content"] isKindOfClass:[NSDictionary class]]){
            NSDictionary *countDict = (NSDictionary *)[dict objectForKey:@"content"];
            NSString *activity_err =[NSString stringWithFormat:@"%@",countDict[@"activity_err"]];
            if ([activity_err isEqualToString:@"0"]) {
                
                NSString *is_prize =[NSString stringWithFormat:@"%@",countDict[@"is_prize"]];
                if ([is_prize isEqualToString:@"1"]) {
                    NSString *ctime = [NSString stringWithFormat:@"%@",countDict[@"ctime"]];
                    NSString *prize_thumb = [NSString stringWithFormat:@"%@",countDict[@"prize_thumb"]];
                    int timeInt =[ctime intValue];
                    self.timeLable.text = [NSString stringWithFormat:@"中奖时间：%@",dateTimeWithNString(timeInt)];
                    NSLog(@"timeInt = %d,time = %@",timeInt,[NSString stringWithFormat:@"中奖时间：%@",dateTimeWithNString(timeInt)]);
                    [self.dataImgView sd_setImageWithURL:[NSURL URLWithString:prize_thumb] placeholderImage:[UIImage imageNamed:@"placehold_hotnews"]];
                }else{
                    self.timeLable.text = [NSString stringWithFormat:@"很遗憾,您还没有中奖记录!"];
                    [self.dataImgView setImage:[UIImage imageNamed:@"yao_prize_no"]];
                }
            }else if ([activity_err isEqualToString:@"1"]){
                //未报名
                self.timeLable.text = [NSString stringWithFormat:@"很遗憾,您还没有中奖记录!"];
                [self.dataImgView setImage:[UIImage imageNamed:@"yao_prize_no"]];
                [[[iToast makeText:@"未报名"]setGravity:iToastGravityCenter] show];
    
                
            }else{
                //没有参加考试
                self.timeLable.text = [NSString stringWithFormat:@"很遗憾,您还没有中奖记录!"];
                [self.dataImgView setImage:[UIImage imageNamed:@"yao_prize_no"]];
                [[[iToast makeText:@"没有参加考试"]setGravity:iToastGravityCenter] show];
            }
        }
    } failure:^(NSError *error) {
        
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)backButtonClick:(UIButton *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}


@end
